from tkinter import *
from get_data import CatchPICFromVideo
from train import *
import tkinter.messagebox as messagebox
import os
from predict import *

root = Tk()

root.title('人脸识别例子GUI')



# root.option_add("Font", "Arial")

def get_faces():
    CatchPICFromVideo("Pictures",100,"./data/me")

def train_faces():
    if os.path.exists('./model/model.h5') == True:
        os.remove('./model/model.h5')
    else:
        print("")
    dataset = Dataset("./data")
    dataset.load()

    model = Model()
    model.build_model(dataset)

    messagebox.showinfo('提示', "模型正在训练中，请稍等！")
    model.train(dataset,nb_epoch=50)
    model.evaluate(dataset)
    model.save_model("./model/model.h5")
    messagebox.showinfo('提示', "模型训练完成！")
    pass

def predict_face():
    pred()

root.geometry('350x250')

get_faces = Button(root,text='获取人脸数据',width=11,command=get_faces)
get_faces.pack()

train_faces = Button(root,text='训练人脸数据',width=11,command=train_faces)
train_faces.pack()

predict_faces = Button(root,text='识别人脸',width=11,command=predict_face)
predict_faces.pack()



if __name__ == '__main__':
    root.mainloop()